package com.example.machine.mapper;


import com.example.machine.model.MachineInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2024-02-19
 * Time: 10:48
 */
@Mapper
public interface MachineInfoMapper {
    @Select("select * from machine_info where status != 0" +
            " order by id desc limit #{offset},#{pageSize}")
    List<MachineInfo> selectMachineInfoByPage(Integer offset, Integer pageSize);

    @Select("select count(1) from machine_info where status != 0")
    Integer count();

    @Insert("insert into machine_info(machine_name,machineSN,position,testTime,publish,status)" +
            "values(#{machineName},#{machineSN},#{position},#{testTime},#{publish},#{status})")
    Integer insertMachine(MachineInfo machineInfo);

    @Select("select * from machine_info where id = #{id}")
    MachineInfo queryMachineInfoById(Integer id);

    Integer updateMachine(MachineInfo machineInfo);

    Integer batchDelete(List<Integer> ids);
}
